﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

public partial class NewsDetail : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request.QueryString["majorid"] != null && Request.QueryString["newsid"] != null)
        {
            string sMajorID = Request.QueryString["majorid"].ToString();
            ModelInfo modelInfo = WebMake.getModelInfo(sMajorID);

            //读取网页
            string sIndex = WebMake.getModel(modelInfo.NewsDetail);
            sIndex = WebMake.ReplaceAllTag(sIndex, modelInfo, sMajorID, Request);

            //文章内容部分<#TITLE>标题 <#CONTENT> 内容,<#INFORMATION> 信息
            SqlDataSource ds = new SqlDataSource();
            ds.ConnectionString = System.Web.Configuration.WebConfigurationManager.ConnectionStrings["Jxzy_Database"].ToString();
            ds.SelectCommand = "select * from zyk_News where News_ID=@newsid order by News_ModifyDate";
            ds.SelectParameters.Add("newsid", Request.QueryString["newsid"].ToString());
            DataView dv = (DataView)ds.Select(DataSourceSelectArguments.Empty);
            if (dv != null & dv.Count > 0)
            {
                WebMake.addNewsVisit(dv[0]["News_ID"].ToString());
                sIndex = sIndex.Replace("<#TITLE>", dv[0]["News_Title"].ToString());
                sIndex = sIndex.Replace("<#CONTENT>", dv[0]["News_Content"].ToString());
                sIndex = sIndex.Replace("<#INFORMATION>", "作者：" + dv[0]["News_Writer"].ToString() + " 时间：" + dv[0]["News_ModifyDate"].ToString() + "  阅读数：" + dv[0]["News_Visit"].ToString());
            }
            else
            {
                sIndex = sIndex.Replace("<#CONTENT>", "没有找到记录");
            }
            Response.Clear();
            Response.Write(sIndex);
            Response.End();
        }
    }
}
